home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Pascal / Games / Stella Obscura 1.1 / source / Parts ƒ / TheMenus.p < prev    next >
Encoding:
Text File  |  1993-06-03  |  5.8 KB  |  254 lines  |  [TEXT/PJMM]

  1. unit TheMenus;
  2.  
  3. interface
  4.  
  5.     uses
  6.         aboutIt, howToView, viewerConstruct, gamePlay, Sound, SomeGlobals, Utilities, mainWndo, Initialize;
  7.  
  8.     procedure Handle_My_Menu (var doneFlag: boolean; theMenu, theItem: integer; var theInput: TEHandle); {Handle menu selection}
  9.  
  10. implementation
  11.  
  12. {=================================}
  13.  
  14.     procedure SetUp;
  15.         var
  16.             index: Integer;
  17.     begin
  18.         SetEventMask(playMask);
  19.         FlushEvents(everyEvent, 0);
  20.         HideCursor;
  21.         DisableItem(GetMenu(AppleM), 0);
  22.         DisableItem(GetMenu(GameM), 1);
  23.         EnableItem(GetMenu(GameM), 2);
  24.         EnableItem(GetMenu(GameM), 3);
  25.         DisableItem(GetMenu(OptionsM), 0);
  26.  
  27.         levelOn := 1;
  28.         gameOver := FALSE;
  29.         enemiesPassed := 0;
  30.         enemyMax := 10;
  31.         enemySpeed := 6;
  32.  
  33.         SetShipsPos;
  34.         oldLeftShip := leftShipDst;
  35.         oldRightShip := rightShipDst;
  36.         oldLeftCrossHair := leftCrossHairDst;
  37.         oldRightCrossHair := rightCrossHairDst;
  38.  
  39.         PredefineEnemyRects;
  40.         for index := 1 to numberOfEnemies do
  41.             begin
  42.                 playerShot[index] := FALSE;
  43.                 enemyShot[index] := FALSE;
  44.                 currentEnemies[index, currentPointer] := index;
  45.                 currentEnemies[index, dataDimension] := index;
  46.             end;
  47.  
  48.         chanPtr := nil;
  49.         fireMode := 0;
  50.         shields := 10;
  51.         NumToString(shields, shieldString);
  52.         theScore := 0;
  53.         NumToString(theScore, scoreString);
  54.         hoopOut := FALSE;
  55.         hoopAngle := 1;
  56.         hoopDistance := farthest;
  57.         ComputeHoops;
  58.  
  59.         SetPort(mainWndo);
  60.         PenNormal;
  61.         TextFont(1);
  62.         TextSize(9);
  63.         TextMode(NotSrcCopy);
  64.         MoveTo(141, 70);
  65.         DrawString('Get your viewer');
  66.         MoveTo(141, 80);
  67.         DrawString('set up and ready.');
  68.         MoveTo(141, 110);
  69.         DrawString('Relax your eyes');
  70.         MoveTo(141, 120);
  71.         DrawString('until the two');
  72.         MoveTo(141, 130);
  73.         DrawString('images converge.');
  74.         MoveTo(141, 165);
  75.         DrawString('Click the mouse');
  76.         MoveTo(141, 175);
  77.         DrawString('when ready.');
  78.  
  79.         MoveTo(263, 70);
  80.         DrawString('Get your viewer');
  81.         MoveTo(263, 80);
  82.         DrawString('set up and ready.');
  83.         MoveTo(263, 110);
  84.         DrawString('Relax your eyes');
  85.         MoveTo(263, 120);
  86.         DrawString('until the two');
  87.         MoveTo(263, 130);
  88.         DrawString('images converge.');
  89.         MoveTo(263, 165);
  90.         DrawString('Click the mouse');
  91.         MoveTo(263, 175);
  92.         DrawString('when ready.');
  93.  
  94.         repeat
  95.         until (not button);
  96.         repeat
  97.         until (button);
  98.         IntroEffects;
  99.     end;
  100.  
  101. {=================================}
  102.  
  103.     procedure Handle_My_Menu;               {Handle menu selections realtime}
  104.         const
  105.             L_Apple = 201;                        {Menu list}
  106.             C_About_Game = 1;
  107.             L_Game = 202;                         {Menu list}
  108.             C_Begin = 1;
  109.             C_Pause = 2;
  110.             C_End = 3;
  111.             C_Quit = 5;
  112.             L_Options = 203;                      {Menu list}
  113.             C_Set_Controls = 1;
  114.             C_Configure = 2;
  115.             C_Help1 = 4;
  116.             C_Help2 = 5;
  117.             C_Help3 = 6;
  118.         var
  119.             DNA: integer;
  120.             BoolHolder: boolean;
  121.             DAName: Str255;
  122.             SavePort: GrafPtr;
  123.             err: OSErr;
  124.  
  125.     begin
  126.         case theMenu of
  127.             L_Apple: 
  128.                 begin
  129.                     case theItem of
  130.                         C_About_Game: 
  131.                             begin
  132.                                 D_aboutIt;
  133.                             end;
  134.                         otherwise
  135.                             begin
  136.                                 GetPort(SavePort);
  137.                                 GetItem(AppleMenu, theItem, DAName);
  138.                                 DNA := OpenDeskAcc(DAName);
  139.                                 SetPort(SavePort);
  140.                             end;
  141.                     end;
  142.                 end;
  143.             L_Game: 
  144.                 begin
  145.                     case theItem of                   {Handle all commands in this menu list}
  146.                         C_Begin: 
  147.                             begin
  148.                                 playing := TRUE;
  149.                                 pausing := FALSE;
  150.                                 SetUp;
  151.                             end;
  152.                         C_Pause: 
  153.                             begin
  154.                                 pausing := not pausing;
  155.                                 if pausing then
  156.                                     begin
  157.                                         ShowCursor;
  158.                                         SetItem(GetMenu(GameM), 2, 'Continue');
  159.                                         SetEventMask(idleMask);
  160.                                         FlushEvents(everyEvent, 0);
  161.                                         if (chanPtr <> nil) then
  162.                                             begin
  163.                                                 err := SndDisposeChannel(chanPtr, FALSE);
  164.                                                 chanPtr := nil;
  165.                                             end;
  166.                                     end
  167.                                 else
  168.                                     begin
  169.                                         HideCursor;
  170.                                         SetItem(GetMenu(GameM), 2, 'Pause');
  171.                                         SetEventMask(playMask);
  172.                                         FlushEvents(everyEvent, 0);
  173.                                         if (chanPtr <> nil) then
  174.                                             begin
  175.                                                 err := SndDisposeChannel(chanPtr, FALSE);
  176.                                                 chanPtr := nil;
  177.                                             end;
  178.                                     end;
  179.                             end;
  180.                         C_End: 
  181.                             begin
  182.                                 ShowCursor;
  183.                                 EnableItem(GetMenu(AppleM), 0);
  184.                                 EnableItem(GetMenu(GameM), 1);
  185.                                 DisableItem(GetMenu(GameM), 2);
  186.                                 DisableItem(GetMenu(GameM), 3);
  187.                                 EnableItem(GetMenu(OptionsM), 0);
  188.                                 playing := FALSE;
  189.                                 pausing := FALSE;
  190.                                 SetEventMask(idleMask);
  191.                                 FlushEvents(everyEvent, 0);
  192.                             end;
  193.                         C_Quit: 
  194.                             begin
  195.                                 ShowCursor;
  196.                                 doneFlag := TRUE;
  197.                                 playing := FALSE;
  198.                                 pausing := FALSE;
  199.                                 SetEventMask(EveryEvent);
  200.                                 FlushEvents(everyEvent, 0);
  201.                                 if (chanPtr <> nil) then
  202.                                     begin
  203.                                         err := SndDisposeChannel(chanPtr, FALSE);
  204.                                         chanPtr := nil;
  205.                                     end;
  206.                             end;
  207.                         otherwise
  208.                             begin
  209.                             end;
  210.                     end;
  211.                 end;
  212.             L_Options: 
  213.                 begin                             {Handle by using a Case statment}
  214.                     case theItem of                 {Handle all commands in this menu list}
  215.                         C_Set_Controls:     {Sound actually}
  216.                             begin
  217.                                 soundOn := not soundOn;
  218.                                 if soundOn then
  219.                                     SetItem(GetMenu(OptionsM), 1, 'Turn Off Sound')
  220.                                 else
  221.                                     SetItem(GetMenu(OptionsM), 1, 'Turn Sound On');
  222.                             end;
  223.                         C_Configure:         {Actually game speed}
  224.                             begin
  225.                                 slowOn := not slowOn;
  226.                                 if slowOn then
  227.                                     SetItem(GetMenu(OptionsM), 2, 'Speed It Up')
  228.                                 else
  229.                                     SetItem(GetMenu(OptionsM), 2, 'Slow It Down');
  230.                             end;
  231.                         C_Help1: 
  232.                             begin
  233.                                 D_viewerConstruct;
  234.                             end;
  235.                         C_Help2: 
  236.                             begin
  237.                                 D_howToView;
  238.                             end;
  239.                         C_Help3: 
  240.                             begin
  241.                                 D_gamePlay;
  242.                             end;
  243.                         otherwise
  244.                             begin
  245.                             end;
  246.                     end;
  247.                 end;
  248.             otherwise
  249.                 begin
  250.                 end;
  251.         end;
  252.         HiliteMenu(0);
  253.     end;
  254. end.                                    {End of unit}